<?php

/**
 * This is the model class for table "{{menu_item}}".
 *
 * The followings are the available columns in table '{{menu_item}}':
 * @property string $id
 * @property integer $order
 * @property integer $menu_id
 * @property string $label
 * @property string $link
 * @property string $status
 * @property integer $left_id
 * @property integer $right_id
 * @property integer $parent_id
 * @property integer $create_user_id
 * @property string $create_date
 * @property integer $update_user_id
 * @property string $update_date
 */
class MenuItem extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return MenuItem the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{menu_item}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('order, menu_id, label, link, left_id, right_id, parent_id', 'required'),
			array('status,order, menu_id, left_id, right_id, parent_id, create_user_id, update_user_id', 'numerical', 'integerOnly'=>true),
			array('label', 'length', 'max'=>200),
			array('create_date, update_date', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, order, menu_id, label,status, link, left_id, right_id, parent_id, create_user_id, create_date, update_user_id, update_date', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'order' => 'Order',
			'menu_id' => 'Menu',
			'label' => 'Label',
			'link' => 'Link',
			'status' => 'Status',
			'left_id' => 'Left',
			'right_id' => 'Right',
			'parent_id' => 'Parent',
			'create_user_id' => 'Create User',
			'create_date' => 'Create Date',
			'update_user_id' => 'Update User',
			'update_date' => 'Update Date',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id,true);
		$criteria->compare('order',$this->order);
		$criteria->compare('menu_id',$this->menu_id);
		$criteria->compare('label',$this->label,true);
		$criteria->compare('link',$this->link,true);
		$criteria->compare('status',$this->status,true);
		$criteria->compare('left_id',$this->left_id);
		$criteria->compare('right_id',$this->right_id);
		$criteria->compare('parent_id',$this->parent_id);
		$criteria->compare('create_user_id',$this->create_user_id);
		$criteria->compare('create_date',$this->create_date,true);
		$criteria->compare('update_user_id',$this->update_user_id);
		$criteria->compare('update_date',$this->update_date,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}